<!-- 我的设置 -->
<template>
	<view class="mine-edit">
		<view class="sign">完善您的个人信息有助于我们为您提供更好的会员服务</view>
		<uniForms class="form">
			<formListItem class="item" :read-only="true" :label="'手机'" placeholder="未填写" :input-text-align="'right'" :value="userEditFrom.mobile"></formListItem>
			<formListItem
				class="item"
				:read-only="true"
				:label="'昵称'"
				:type="'route'"
				:route-link="'/pages/mine/mine-edit-item?name=昵称&key=userNick&value=' + userEditFrom.userNick"
				placeholder="未填写"
				:input-text-align="'right'"
				:arrow-show="true"
				:value="userEditFrom.userNick"
			></formListItem>
			<formListItem
				class="item"
				:read-only="true"
				:label="'学校'"
				:type="'route'"
				:route-link="'/pages/mine/mine-edit-item?name=学校&key=school&value=' + userEditFrom.school"
				placeholder="未填写"
				:input-text-align="'right'"
				:arrow-show="true"
				:value="userEditFrom.school"
			></formListItem>
			<formListItem
				class="item"
				:read-only="true"
				:label="'班级'"
				:type="'route'"
				:route-link="'/pages/mine/mine-edit-item?name=班级&key=grade&value=' + userEditFrom.grade"
				placeholder="未填写"
				:input-text-align="'right'"
				:arrow-show="true"
				:value="userEditFrom.grade"
			></formListItem>
		</uniForms>
		<button v-if="type=='eidt'" class="btn btn-orange logout-btn" @click="logOut">退出账号</button>
		<button v-if="type=='replenish'" class="btn btn-yellow logout-btn" @click="goBack">返回</button>
	</view>
</template>

<script>
import uniForms from '@/components/uni-forms/uni-forms.vue';
import formListItem from '@/components/form-list-item/form-list-item.vue';
export default {
	components: {
		uniForms,
		formListItem
	},

	data() {
		return {
			type:"eidt", //类型 编辑：eidt 补充：replenish
			userEditFrom: this.$store.state.userModule.userEditFrom
			// userInfo:{
			// 	phone:'18202074132', //手机
			// 	userName:'', //账号
			// 	schoolName:'', //学校名
			// 	className:'' //班级
			// }
		};
	},
	computed: {
		// userEditFrom(){
		// 	return this.$store.state.userModule.userEditFrom
		// }
	},
	watch: {
		'$store.state.userModule.userEditFrom': function(newVal, oldVal) {
			this.userEditFrom = newVal;
		}
	},
	methods: {
		logOut() {
			// 退出
			this.$store.dispatch('logOut');
			this.$store.commit('clearOrderCount');
			uni.showToast({
				mask: true,
				duration: 2000,
				title: '退出成功'
			});
			setTimeout(() => {
				uni.navigateBack({
					delta: 1
				});
			}, 2000);
		},
		goBack() {
			// 返回
			uni.navigateBack({
				delta: 1
			});
		}
	},
	onLoad(option) {
		if(option&&option.type)
		this.type=option.type
		
	}
};
</script>

<style lang="scss" scoped>
.mine-edit {
	width: 100%;
	.sign {
		width: 100%;
		font-size: 28rpx;
		color: #8c8e9c;
		text-align: center;
		margin-top: 16rpx;
	}
	.form {
		width: 100%;
		box-sizing: border-box;
		.item {
			display: flex;
			width: 100%;
			padding: 0rpx 20rpx;
			background-color: #fff;
			box-sizing: border-box;
		}
		.item:nth-child(1) {
			border-radius: 8px 8px 0px 0px;
		}
		.item:nth-last-child(1) {
			border-radius: 0px 0px 8px 8px;
		}
		.item:nth-last-child(n + 2) {
			border-bottom: 2rpx solid #efeff0;
		}
	}
	.logout-btn {
		display: block;
		width: 90%;
		font-size: 30rpx;
		padding: 14rpx 0rpx;
		margin: auto;
		margin-top: 150rpx;
	}
}
</style>
